<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Final C</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
function togglePopup(material_id) {
  var popup = document.getElementById(material_id);
  popup.classList.toggle("show");
}
</script>

<link href="../docs-assets/Popups.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Extracts-Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Final C' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../intern.html">Inter Modules</a></li><li><a href="index.html">final</a></li><li><a href="index.html#5">Chapter 5: C</a></li><li><b>Final C</b></li></ul></div>
<p class="purpose">To generate ANSI C-99 code from intermediate code.</p>

<ul class="toc"><li><a href="5-fnc.html#SP1">&#167;1. Target</a></li><li><a href="5-fnc.html#SP2">&#167;2. Segmentation</a></li><li><a href="5-fnc.html#SP5">&#167;5. Begin and end</a></li><li><a href="5-fnc.html#SP8">&#167;8. Static supporting code</a></li></ul><hr class="tocbar">

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. Target.</b>This generator produces C source code, using the Vanilla algorithm.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CTarget::create_generator</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">CTarget::create_generator</span></span>:<br/>Code Generators - <a href="2-cg2.html#SP3">&#167;3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">code_generator</span><span class="plain-syntax"> *</span><span class="identifier-syntax">C_generator</span><span class="plain-syntax"> = </span><a href="2-cg2.html#SP1" class="function-link"><span class="function-syntax">Generators::new</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"c"</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">METHOD_ADD</span><span class="plain-syntax">(</span><span class="identifier-syntax">C_generator</span><span class="plain-syntax">, </span><span class="constant-syntax">BEGIN_GENERATION_MTID</span><span class="plain-syntax">, </span><a href="5-fnc.html#SP5" class="function-link"><span class="function-syntax">CTarget::begin_generation</span></a><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">METHOD_ADD</span><span class="plain-syntax">(</span><span class="identifier-syntax">C_generator</span><span class="plain-syntax">, </span><span class="constant-syntax">END_GENERATION_MTID</span><span class="plain-syntax">, </span><a href="5-fnc.html#SP6" class="function-link"><span class="function-syntax">CTarget::end_generation</span></a><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><a href="5-cpc.html#SP1" class="function-link"><span class="function-syntax">CProgramControl::initialise</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">C_generator</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-cnm.html#SP1" class="function-link"><span class="function-syntax">CNamespace::initialise</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">C_generator</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-cmm.html#SP1" class="function-link"><span class="function-syntax">CMemoryModel::initialise</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">C_generator</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-cfm.html#SP1" class="function-link"><span class="function-syntax">CFunctionModel::initialise</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">C_generator</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-com.html#SP1" class="function-link"><span class="function-syntax">CObjectModel::initialise</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">C_generator</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-clt.html#SP1" class="function-link"><span class="function-syntax">CLiteralsModel::initialise</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">C_generator</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-cgv.html#SP1" class="function-link"><span class="function-syntax">CGlobals::initialise</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">C_generator</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-cas.html#SP1" class="function-link"><span class="function-syntax">CAssembly::initialise</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">C_generator</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-cim.html#SP1" class="function-link"><span class="function-syntax">CInputOutputModel::initialise</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">C_generator</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. Segmentation.</b>This generator produces two files: a primary one implementing the Inter program
in C, and a secondary header file defining certain constants so that external
code can interface with it. Both are divided into segments. The main file thus:
</p>

<pre class="definitions code-font"><span class="definition-keyword">enum</span> <span class="constant-syntax">c_header_inclusion_I7CGS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">c_ids_and_maxima_I7CGS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">c_function_predeclarations_I7CGS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">c_library_inclusion_I7CGS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">c_predeclarations_I7CGS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">c_actions_I7CGS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">c_quoted_text_I7CGS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">c_constants_I7CGS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">c_text_literals_code_I7CGS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">c_arrays_I7CGS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">c_function_declarations_I7CGS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">c_verb_arrays_I7CGS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">c_function_callers_I7CGS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">c_memory_array_I7CGS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">c_globals_array_I7CGS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">c_initialiser_I7CGS</span>
</pre>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">C_target_segments</span><span class="plain-syntax">[] = {</span>
<span class="plain-syntax">    </span><span class="constant-syntax">c_header_inclusion_I7CGS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="constant-syntax">c_ids_and_maxima_I7CGS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="constant-syntax">c_function_predeclarations_I7CGS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="constant-syntax">c_library_inclusion_I7CGS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="constant-syntax">c_predeclarations_I7CGS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="constant-syntax">c_actions_I7CGS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="constant-syntax">c_quoted_text_I7CGS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="constant-syntax">c_constants_I7CGS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="constant-syntax">c_text_literals_code_I7CGS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="constant-syntax">c_arrays_I7CGS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="constant-syntax">c_function_declarations_I7CGS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="constant-syntax">c_verb_arrays_I7CGS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="constant-syntax">c_function_callers_I7CGS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="constant-syntax">c_memory_array_I7CGS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="constant-syntax">c_globals_array_I7CGS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="constant-syntax">c_initialiser_I7CGS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    -1</span>
<span class="plain-syntax">};</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. </b>And the header file thus:
</p>

<pre class="definitions code-font"><span class="definition-keyword">enum</span> <span class="constant-syntax">c_instances_symbols_I7CGS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">c_enum_symbols_I7CGS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">c_kinds_symbols_I7CGS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">c_actions_symbols_I7CGS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">c_property_symbols_I7CGS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">c_variable_symbols_I7CGS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">c_function_symbols_I7CGS</span>
</pre>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">C_symbols_header_segments</span><span class="plain-syntax">[] = {</span>
<span class="plain-syntax">    </span><span class="constant-syntax">c_instances_symbols_I7CGS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="constant-syntax">c_enum_symbols_I7CGS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="constant-syntax">c_kinds_symbols_I7CGS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="constant-syntax">c_actions_symbols_I7CGS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="constant-syntax">c_property_symbols_I7CGS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="constant-syntax">c_variable_symbols_I7CGS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="constant-syntax">c_function_symbols_I7CGS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    -1</span>
<span class="plain-syntax">};</span>
</pre>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. </b>This generator uses the following state data while it works:
</p>

<pre class="definitions code-font"><span class="definition-keyword">define</span> <span class="identifier-syntax">C_GEN_DATA</span><span class="plain-syntax">(</span><span class="identifier-syntax">x</span><span class="plain-syntax">) ((</span><span class="reserved-syntax">C_generation_data</span><span class="plain-syntax"> *) (</span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">generator_private_data</span><span class="plain-syntax">))-&gt;</span><span class="identifier-syntax">x</span>
</pre>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">C_generation_data</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">compile_main</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">compile_symbols</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">dictionary</span><span class="plain-syntax"> *</span><span class="identifier-syntax">symbols_header_identifiers</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">C_generation_assembly_data</span><span class="plain-syntax"> </span><span class="identifier-syntax">asmdata</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">C_generation_memory_model_data</span><span class="plain-syntax"> </span><span class="identifier-syntax">memdata</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">C_generation_function_model_data</span><span class="plain-syntax"> </span><span class="identifier-syntax">fndata</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">C_generation_object_model_data</span><span class="plain-syntax"> </span><span class="identifier-syntax">objdata</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">C_generation_literals_model_data</span><span class="plain-syntax"> </span><span class="identifier-syntax">litdata</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">C_generation_variables_data</span><span class="plain-syntax"> </span><span class="identifier-syntax">vardata</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">C_generation_data</span><span class="plain-syntax">;</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CTarget::initialise_data</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">CTarget::initialise_data</span></span>:<br/><a href="5-fnc.html#SP5">&#167;5</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">code_generation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">gen</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">C_GEN_DATA</span><span class="plain-syntax">(</span><span class="identifier-syntax">compile_main</span><span class="plain-syntax">) = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">C_GEN_DATA</span><span class="plain-syntax">(</span><span class="identifier-syntax">compile_symbols</span><span class="plain-syntax">) = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">C_GEN_DATA</span><span class="plain-syntax">(</span><span class="identifier-syntax">symbols_header_identifiers</span><span class="plain-syntax">) = </span><span class="identifier-syntax">Dictionaries::new</span><span class="plain-syntax">(1024, </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-cmm.html#SP1" class="function-link"><span class="function-syntax">CMemoryModel::initialise_data</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-cfm.html#SP1" class="function-link"><span class="function-syntax">CFunctionModel::initialise_data</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-com.html#SP2" class="function-link"><span class="function-syntax">CObjectModel::initialise_data</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-clt.html#SP1" class="function-link"><span class="function-syntax">CLiteralsModel::initialise_data</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-cgv.html#SP1" class="function-link"><span class="function-syntax">CGlobals::initialise_data</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-cas.html#SP1" class="function-link"><span class="function-syntax">CAssembly::initialise_data</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-cim.html#SP1" class="function-link"><span class="function-syntax">CInputOutputModel::initialise_data</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>The structure C_generation_data is private to this section.</li></ul>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. Begin and end.</b>We return <span class="extract"><span class="extract-syntax">FALSE</span></span> here to signal that we want the Vanilla algorithm to
manage the process.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">CTarget::begin_generation</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">CTarget::begin_generation</span></span>:<br/><a href="5-fnc.html#SP1">&#167;1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">code_generator</span><span class="plain-syntax"> *</span><span class="identifier-syntax">gtr</span><span class="plain-syntax">, </span><span class="reserved-syntax">code_generation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">gen</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><a href="2-cg.html#SP10" class="function-link"><span class="function-syntax">CodeGen::create_segments</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">C_generation_data</span><span class="plain-syntax">), </span><span class="identifier-syntax">C_target_segments</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="2-cg.html#SP11" class="function-link"><span class="function-syntax">CodeGen::additional_segments</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="identifier-syntax">C_symbols_header_segments</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-fnc.html#SP4" class="function-link"><span class="function-syntax">CTarget::initialise_data</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="5-fnc.html#SP5_1" class="named-paragraph-link"><span class="named-paragraph">Parse the C compilation options</span><span class="named-paragraph-number">5.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="5-fnc.html#SP5_2" class="named-paragraph-link"><span class="named-paragraph">Compile the Clib header inclusion and some clang pragmas</span><span class="named-paragraph-number">5.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="5-fnc.html#SP5_3" class="named-paragraph-link"><span class="named-paragraph">Compile the Clib code inclusion</span><span class="named-paragraph-number">5.3</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="5-fnc.html#SP5_4" class="named-paragraph-link"><span class="named-paragraph">Default the dictionary resolution</span><span class="named-paragraph-number">5.4</span></a></span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><a href="5-cnm.html#SP6" class="function-link"><span class="function-syntax">CNamespace::fix_locals</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-cmm.html#SP2" class="function-link"><span class="function-syntax">CMemoryModel::begin</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-cfm.html#SP1" class="function-link"><span class="function-syntax">CFunctionModel::begin</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-com.html#SP2" class="function-link"><span class="function-syntax">CObjectModel::begin</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-clt.html#SP1" class="function-link"><span class="function-syntax">CLiteralsModel::begin</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-cgv.html#SP2" class="function-link"><span class="function-syntax">CGlobals::begin</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-cas.html#SP1" class="function-link"><span class="function-syntax">CAssembly::begin</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-cim.html#SP1" class="function-link"><span class="function-syntax">CInputOutputModel::begin</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5_1" class="paragraph-anchor"></a><b>&#167;5.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Parse the C compilation options</span><span class="named-paragraph-number">5.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">opts</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TargetVMs::option_list</span><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">for_VM</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">opt</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">opt</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax">, </span><span class="identifier-syntax">opts</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::eq_insensitive</span><span class="plain-syntax">(</span><span class="identifier-syntax">opt</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"main"</span><span class="plain-syntax">)) </span><span class="identifier-syntax">C_GEN_DATA</span><span class="plain-syntax">(</span><span class="identifier-syntax">compile_main</span><span class="plain-syntax">) = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::eq_insensitive</span><span class="plain-syntax">(</span><span class="identifier-syntax">opt</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"no-main"</span><span class="plain-syntax">)) </span><span class="identifier-syntax">C_GEN_DATA</span><span class="plain-syntax">(</span><span class="identifier-syntax">compile_main</span><span class="plain-syntax">) = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::eq_insensitive</span><span class="plain-syntax">(</span><span class="identifier-syntax">opt</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"symbols-header"</span><span class="plain-syntax">)) </span><span class="identifier-syntax">C_GEN_DATA</span><span class="plain-syntax">(</span><span class="identifier-syntax">compile_symbols</span><span class="plain-syntax">) = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::eq_insensitive</span><span class="plain-syntax">(</span><span class="identifier-syntax">opt</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"no-symbols-header"</span><span class="plain-syntax">)) </span><span class="identifier-syntax">C_GEN_DATA</span><span class="plain-syntax">(</span><span class="identifier-syntax">compile_symbols</span><span class="plain-syntax">) = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">            #</span><span class="identifier-syntax">ifdef</span><span class="plain-syntax"> </span><span class="identifier-syntax">PROBLEMS_MODULE</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Problems::fatal</span><span class="plain-syntax">(</span><span class="string-syntax">"Unknown compilation format option"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            #</span><span class="identifier-syntax">endif</span>
<span class="plain-syntax">            #</span><span class="identifier-syntax">ifndef</span><span class="plain-syntax"> </span><span class="identifier-syntax">PROBLEMS_MODULE</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Errors::fatal</span><span class="plain-syntax">(</span><span class="string-syntax">"Unknown compilation format option"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">exit</span><span class="plain-syntax">(1);</span>
<span class="plain-syntax">            #</span><span class="identifier-syntax">endif</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-fnc.html#SP5">&#167;5</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP5_2" class="paragraph-anchor"></a><b>&#167;5.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Compile the Clib header inclusion and some clang pragmas</span><span class="named-paragraph-number">5.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">segmentation_pos</span><span class="plain-syntax"> </span><span class="identifier-syntax">saved</span><span class="plain-syntax"> = </span><a href="2-cg.html#SP12" class="function-link"><span class="function-syntax">CodeGen::select</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="constant-syntax">c_header_inclusion_I7CGS</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">OUT</span><span class="plain-syntax"> = </span><a href="2-cg.html#SP14" class="function-link"><span class="function-syntax">CodeGen::current</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Architectures::debug_enabled</span><span class="plain-syntax">(</span><span class="identifier-syntax">TargetVMs::get_architecture</span><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">for_VM</span><span class="plain-syntax">)))</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"#define DEBUG\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"#include \"inform7_clib.h\"\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">C_GEN_DATA</span><span class="plain-syntax">(</span><span class="identifier-syntax">compile_main</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"int main(int argc, char **argv) { return i7_default_main(argc, argv); }\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"#pragma clang diagnostic push\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"#pragma clang diagnostic ignored \"-Wunused-value\"\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"#pragma clang diagnostic ignored \"-Wparentheses-equality\"\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="2-cg.html#SP12" class="function-link"><span class="function-syntax">CodeGen::deselect</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="identifier-syntax">saved</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-fnc.html#SP5">&#167;5</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP5_3" class="paragraph-anchor"></a><b>&#167;5.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Compile the Clib code inclusion</span><span class="named-paragraph-number">5.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">segmentation_pos</span><span class="plain-syntax"> </span><span class="identifier-syntax">saved</span><span class="plain-syntax"> = </span><a href="2-cg.html#SP12" class="function-link"><span class="function-syntax">CodeGen::select</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="constant-syntax">c_library_inclusion_I7CGS</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">OUT</span><span class="plain-syntax"> = </span><a href="2-cg.html#SP14" class="function-link"><span class="function-syntax">CodeGen::current</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"#include \"inform7_clib.c\"\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="2-cg.html#SP12" class="function-link"><span class="function-syntax">CodeGen::deselect</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="identifier-syntax">saved</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-fnc.html#SP5">&#167;5</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP5_4" class="paragraph-anchor"></a><b>&#167;5.4. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Default the dictionary resolution</span><span class="named-paragraph-number">5.4</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">dictionary_resolution</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">segmentation_pos</span><span class="plain-syntax"> </span><span class="identifier-syntax">saved</span><span class="plain-syntax"> = </span><a href="2-cg.html#SP12" class="function-link"><span class="function-syntax">CodeGen::select</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="constant-syntax">c_ids_and_maxima_I7CGS</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">OUT</span><span class="plain-syntax"> = </span><a href="2-cg.html#SP14" class="function-link"><span class="function-syntax">CodeGen::current</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"#define "</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="5-cnm.html#SP3" class="function-link"><span class="function-syntax">CNamespace::mangle</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gtr</span><span class="plain-syntax">, </span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"DICT_WORD_SIZE"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">" 9\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="2-cg.html#SP12" class="function-link"><span class="function-syntax">CodeGen::deselect</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="identifier-syntax">saved</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-fnc.html#SP5">&#167;5</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. </b>The Inform 6 compiler automatically generates the dictionary, verb and actions
tables, but other compilers do not, of course, so generators for other languages
(such as this one) must ask Vanilla to make those tables for it.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">CTarget::end_generation</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">CTarget::end_generation</span></span>:<br/><a href="5-fnc.html#SP1">&#167;1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">code_generator</span><span class="plain-syntax"> *</span><span class="identifier-syntax">gtr</span><span class="plain-syntax">, </span><span class="reserved-syntax">code_generation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">gen</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="5-fnc.html#SP6_1" class="named-paragraph-link"><span class="named-paragraph">Compile a random function if necessary</span><span class="named-paragraph-number">6.1</span></a></span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><a href="2-vi.html#SP5" class="function-link"><span class="function-syntax">VanillaIF::compile_dictionary_table</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="2-vi.html#SP12" class="function-link"><span class="function-syntax">VanillaIF::compile_verb_table</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="2-vi.html#SP7" class="function-link"><span class="function-syntax">VanillaIF::compile_actions_table</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-cfm.html#SP1" class="function-link"><span class="function-syntax">CFunctionModel::end</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-com.html#SP2" class="function-link"><span class="function-syntax">CObjectModel::end</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-clt.html#SP1" class="function-link"><span class="function-syntax">CLiteralsModel::end</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-cgv.html#SP2" class="function-link"><span class="function-syntax">CGlobals::end</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-cas.html#SP1" class="function-link"><span class="function-syntax">CAssembly::end</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-cim.html#SP1" class="function-link"><span class="function-syntax">CInputOutputModel::end</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-cmm.html#SP3" class="function-link"><span class="function-syntax">CMemoryModel::end</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">); </span><span class="comment-syntax"> must be last to end</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="5-fnc.html#SP6_2" class="named-paragraph-link"><span class="named-paragraph">Compile end to clang pragmas</span><span class="named-paragraph-number">6.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">F</span><span class="plain-syntax"> = </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">to_file</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">F</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">C_GEN_DATA</span><span class="plain-syntax">(</span><span class="identifier-syntax">compile_symbols</span><span class="plain-syntax">))) </span><span class="named-paragraph-container code-font"><a href="5-fnc.html#SP6_3" class="named-paragraph-link"><span class="named-paragraph">String the symbols header target together</span><span class="named-paragraph-number">6.3</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP6_1" class="paragraph-anchor"></a><b>&#167;6.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Compile a random function if necessary</span><span class="named-paragraph-number">6.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">defines_random</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">segmentation_pos</span><span class="plain-syntax"> </span><span class="identifier-syntax">saved</span><span class="plain-syntax"> = </span><a href="2-cg.html#SP12" class="function-link"><span class="function-syntax">CodeGen::select</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="constant-syntax">c_header_inclusion_I7CGS</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">OUT</span><span class="plain-syntax"> = </span><a href="2-cg.html#SP14" class="function-link"><span class="function-syntax">CodeGen::current</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"i7word_t i7_fn_random(i7process_t *proc, i7word_t x) {\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"    i7word_t r; i7_opcode_random(proc, x, &amp;r); return r+1;\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"}\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="2-cg.html#SP12" class="function-link"><span class="function-syntax">CodeGen::deselect</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="identifier-syntax">saved</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-fnc.html#SP6">&#167;6</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP6_2" class="paragraph-anchor"></a><b>&#167;6.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Compile end to clang pragmas</span><span class="named-paragraph-number">6.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">segmentation_pos</span><span class="plain-syntax"> </span><span class="identifier-syntax">saved</span><span class="plain-syntax"> = </span><a href="2-cg.html#SP12" class="function-link"><span class="function-syntax">CodeGen::select</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="constant-syntax">c_initialiser_I7CGS</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">OUT</span><span class="plain-syntax"> = </span><a href="2-cg.html#SP14" class="function-link"><span class="function-syntax">CodeGen::current</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"#pragma clang diagnostic pop\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="2-cg.html#SP12" class="function-link"><span class="function-syntax">CodeGen::deselect</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="identifier-syntax">saved</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-fnc.html#SP6">&#167;6</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP6_3" class="paragraph-anchor"></a><b>&#167;6.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">String the symbols header target together</span><span class="named-paragraph-number">6.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">G</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Filenames::in</span><span class="plain-syntax">(</span><span class="identifier-syntax">Filenames::up</span><span class="plain-syntax">(</span><span class="identifier-syntax">F</span><span class="plain-syntax">), </span><span class="identifier-syntax">I</span><span class="string-syntax">"inform7_symbols.h"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> </span><span class="identifier-syntax">HF</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">STREAM_OPEN_TO_FILE</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">HF</span><span class="plain-syntax">, </span><span class="identifier-syntax">G</span><span class="plain-syntax">, </span><span class="identifier-syntax">ISO_ENC</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        #</span><span class="identifier-syntax">ifdef</span><span class="plain-syntax"> </span><span class="identifier-syntax">PROBLEMS_MODULE</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::fatal_on_file</span><span class="plain-syntax">(</span><span class="string-syntax">"Can't open output file"</span><span class="plain-syntax">, </span><span class="identifier-syntax">G</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        #</span><span class="identifier-syntax">endif</span>
<span class="plain-syntax">        #</span><span class="identifier-syntax">ifndef</span><span class="plain-syntax"> </span><span class="identifier-syntax">PROBLEMS_MODULE</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Errors::fatal_with_file</span><span class="plain-syntax">(</span><span class="string-syntax">"Can't open output file"</span><span class="plain-syntax">, </span><span class="identifier-syntax">G</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">exit</span><span class="plain-syntax">(1);</span>
<span class="plain-syntax">        #</span><span class="identifier-syntax">endif</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">HF</span><span class="plain-syntax">, </span><span class="string-syntax">"/* Symbols derived mechanically from Inform 7 source: do not edit */\n\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">HF</span><span class="plain-syntax">, </span><span class="string-syntax">"/* (1) Instance IDs */\n\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="2-cg.html#SP15" class="function-link"><span class="function-syntax">CodeGen::write_segment</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">HF</span><span class="plain-syntax">, </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">segments</span><span class="plain-syntax">[</span><span class="constant-syntax">c_instances_symbols_I7CGS</span><span class="plain-syntax">]);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">HF</span><span class="plain-syntax">, </span><span class="string-syntax">"\n/* (2) Values of enumerated kinds */\n\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="2-cg.html#SP15" class="function-link"><span class="function-syntax">CodeGen::write_segment</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">HF</span><span class="plain-syntax">, </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">segments</span><span class="plain-syntax">[</span><span class="constant-syntax">c_enum_symbols_I7CGS</span><span class="plain-syntax">]);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">HF</span><span class="plain-syntax">, </span><span class="string-syntax">"\n/* (3) Kind IDs */\n\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="2-cg.html#SP15" class="function-link"><span class="function-syntax">CodeGen::write_segment</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">HF</span><span class="plain-syntax">, </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">segments</span><span class="plain-syntax">[</span><span class="constant-syntax">c_kinds_symbols_I7CGS</span><span class="plain-syntax">]);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">HF</span><span class="plain-syntax">, </span><span class="string-syntax">"\n/* (4) Action IDs */\n\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="2-cg.html#SP15" class="function-link"><span class="function-syntax">CodeGen::write_segment</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">HF</span><span class="plain-syntax">, </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">segments</span><span class="plain-syntax">[</span><span class="constant-syntax">c_actions_symbols_I7CGS</span><span class="plain-syntax">]);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">HF</span><span class="plain-syntax">, </span><span class="string-syntax">"\n/* (5) Property IDs */\n\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="2-cg.html#SP15" class="function-link"><span class="function-syntax">CodeGen::write_segment</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">HF</span><span class="plain-syntax">, </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">segments</span><span class="plain-syntax">[</span><span class="constant-syntax">c_property_symbols_I7CGS</span><span class="plain-syntax">]);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">HF</span><span class="plain-syntax">, </span><span class="string-syntax">"\n/* (6) Variable IDs */\n\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="2-cg.html#SP15" class="function-link"><span class="function-syntax">CodeGen::write_segment</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">HF</span><span class="plain-syntax">, </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">segments</span><span class="plain-syntax">[</span><span class="constant-syntax">c_variable_symbols_I7CGS</span><span class="plain-syntax">]);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">HF</span><span class="plain-syntax">, </span><span class="string-syntax">"\n/* (7) Function IDs */\n\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="2-cg.html#SP15" class="function-link"><span class="function-syntax">CodeGen::write_segment</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">HF</span><span class="plain-syntax">, </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">segments</span><span class="plain-syntax">[</span><span class="constant-syntax">c_function_symbols_I7CGS</span><span class="plain-syntax">]);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">STREAM_CLOSE</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">HF</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-fnc.html#SP6">&#167;6</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. </b>When defining constants to be defined in the symbols header, the following
function is a convenience, automatically ensuring that names never clash:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="function-syntax">CTarget::symbols_header_identifier</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">CTarget::symbols_header_identifier</span></span>:<br/>C Global Variables - <a href="5-cgv.html#SP4">&#167;4</a><br/>C Literals - <a href="5-clt.html#SP8">&#167;8</a><br/>C Object Model - <a href="5-com.html#SP13">&#167;13</a>, <a href="5-com.html#SP16">&#167;16</a>, <a href="5-com.html#SP20_3">&#167;20.3</a><br/>C Function Model - <a href="5-cfm.html#SP14_3">&#167;14.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">code_generation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">gen</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">prefix</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">raw</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">dictionary</span><span class="plain-syntax"> *</span><span class="identifier-syntax">D</span><span class="plain-syntax"> = </span><span class="identifier-syntax">C_GEN_DATA</span><span class="plain-syntax">(</span><span class="identifier-syntax">symbols_header_identifiers</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">key</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::new</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">key</span><span class="plain-syntax">, </span><span class="string-syntax">"i7_%S_"</span><span class="plain-syntax">, </span><span class="identifier-syntax">prefix</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_THROUGH_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">pos</span><span class="plain-syntax">, </span><span class="identifier-syntax">raw</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Characters::isalnum</span><span class="plain-syntax">(</span><span class="identifier-syntax">Str::get</span><span class="plain-syntax">(</span><span class="identifier-syntax">pos</span><span class="plain-syntax">)))</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">PUT_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">key</span><span class="plain-syntax">, </span><span class="identifier-syntax">Str::get</span><span class="plain-syntax">(</span><span class="identifier-syntax">pos</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">PUT_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">key</span><span class="plain-syntax">, </span><span class="character-syntax">'_'</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">dv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Dictionaries::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">D</span><span class="plain-syntax">, </span><span class="identifier-syntax">key</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">dv</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">keyx</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">n</span><span class="plain-syntax"> = </span><span class="constant-syntax">2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Str::clear</span><span class="plain-syntax">(</span><span class="identifier-syntax">keyx</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">keyx</span><span class="plain-syntax">, </span><span class="string-syntax">"%S_%d"</span><span class="plain-syntax">, </span><span class="identifier-syntax">key</span><span class="plain-syntax">, </span><span class="identifier-syntax">n</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Dictionaries::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">D</span><span class="plain-syntax">, </span><span class="identifier-syntax">keyx</span><span class="plain-syntax">) == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">n</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">keyx</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">key</span><span class="plain-syntax">, </span><span class="string-syntax">"_%d"</span><span class="plain-syntax">, </span><span class="identifier-syntax">n</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Dictionaries::create_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">D</span><span class="plain-syntax">, </span><span class="identifier-syntax">key</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. Static supporting code.</b>The C code generated here would not compile as a stand-alone file. It needs
to use variables and functions from a small unchanging library called
<span class="extract"><span class="extract-syntax">inform7_clib.c</span></span>, which has an associated header file <span class="extract"><span class="extract-syntax">inform7_clib.h</span></span> of
declarations so that code can be linked to it. (See the test makes <span class="extract"><span class="extract-syntax">Eg1-C</span></span>,
<span class="extract"><span class="extract-syntax">Eg2-C</span></span> and so on for demonstrations of this.)
</p>

<p class="commentary">Those two files are presented throughout this chapter, because the implementation
of the I7 C library is so closely tied to the code we compile: they can only
really be understood jointly.
</p>

<p class="commentary">Here is the beginning of the header file <span class="extract"><span class="extract-syntax">inform7_clib.h</span></span>:
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-plain-syntax">/* </span><span class="Extracts-identifier-syntax">This</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">is</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">header</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">file</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">for</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">using</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">library</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">of</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">C</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">code</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">to</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">support</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">Inter</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">code</span>
<span class="Extracts-plain-syntax">   </span><span class="Extracts-identifier-syntax">compiled</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">to</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">ANSI</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">C</span><span class="Extracts-plain-syntax">. </span><span class="Extracts-identifier-syntax">It</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">was</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">generated</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">mechanically</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">from</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">the</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">Inter</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">source</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">code</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">   </span><span class="Extracts-identifier-syntax">so</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">to</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">change</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">this</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">material</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">edit</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">that</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">and</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">not</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">this</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">file</span><span class="Extracts-plain-syntax">. */</span>

<span class="Extracts-plain-syntax">#</span><span class="Extracts-identifier-syntax">ifndef</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">I7_CLIB_H_INCLUDED</span>
<span class="Extracts-plain-syntax">#</span><span class="Extracts-identifier-syntax">define</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">I7_CLIB_H_INCLUDED</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">1</span>

<span class="Extracts-plain-syntax">#</span><span class="Extracts-identifier-syntax">include</span><span class="Extracts-plain-syntax"> &lt;</span><span class="Extracts-identifier-syntax">stdlib</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">h</span><span class="Extracts-plain-syntax">&gt;</span>
<span class="Extracts-plain-syntax">#</span><span class="Extracts-identifier-syntax">include</span><span class="Extracts-plain-syntax"> &lt;</span><span class="Extracts-identifier-syntax">stdio</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">h</span><span class="Extracts-plain-syntax">&gt;</span>
<span class="Extracts-plain-syntax">#</span><span class="Extracts-identifier-syntax">include</span><span class="Extracts-plain-syntax"> &lt;</span><span class="Extracts-identifier-syntax">string</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">h</span><span class="Extracts-plain-syntax">&gt;</span>
<span class="Extracts-plain-syntax">#</span><span class="Extracts-identifier-syntax">include</span><span class="Extracts-plain-syntax"> &lt;</span><span class="Extracts-identifier-syntax">math</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">h</span><span class="Extracts-plain-syntax">&gt;</span>
<span class="Extracts-plain-syntax">#</span><span class="Extracts-identifier-syntax">include</span><span class="Extracts-plain-syntax"> &lt;</span><span class="Extracts-identifier-syntax">time</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">h</span><span class="Extracts-plain-syntax">&gt;</span>
<span class="Extracts-plain-syntax">#</span><span class="Extracts-identifier-syntax">include</span><span class="Extracts-plain-syntax"> &lt;</span><span class="Extracts-identifier-syntax">ctype</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">h</span><span class="Extracts-plain-syntax">&gt;</span>
<span class="Extracts-plain-syntax">#</span><span class="Extracts-identifier-syntax">include</span><span class="Extracts-plain-syntax"> &lt;</span><span class="Extracts-identifier-syntax">stdint</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">h</span><span class="Extracts-plain-syntax">&gt;</span>
<span class="Extracts-plain-syntax">#</span><span class="Extracts-identifier-syntax">include</span><span class="Extracts-plain-syntax"> &lt;</span><span class="Extracts-identifier-syntax">setjmp</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">h</span><span class="Extracts-plain-syntax">&gt;</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<p class="commentary">And similarly for <span class="extract"><span class="Extracts-extract-syntax">inform7_clib.c</span></span>:
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-plain-syntax">/* </span><span class="Extracts-identifier-syntax">This</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">is</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">library</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">of</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">C</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">code</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">to</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">support</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">Inter</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">code</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">compiled</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">to</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">ANSI</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">C</span><span class="Extracts-plain-syntax">. </span><span class="Extracts-identifier-syntax">It</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">was</span>
<span class="Extracts-plain-syntax">   </span><span class="Extracts-identifier-syntax">generated</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">mechanically</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">from</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">the</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">Inter</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">source</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">code</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">so</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">to</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">change</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">this</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">material</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">   </span><span class="Extracts-identifier-syntax">edit</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">that</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">and</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">not</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">this</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">file</span><span class="Extracts-plain-syntax">. */</span>

<span class="Extracts-plain-syntax">#</span><span class="Extracts-identifier-syntax">ifndef</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">I7_CLIB_C_INCLUDED</span>
<span class="Extracts-plain-syntax">#</span><span class="Extracts-identifier-syntax">define</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">I7_CLIB_C_INCLUDED</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">1</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. </b>Now we need four fundamental types. <span class="extract"><span class="Extracts-extract-syntax">i7word_t</span></span> is a type which can hold any
Inter word value: since we do not support C for 16-bit Inter code, we can
safely make this a 32-bit integer. <span class="extract"><span class="Extracts-extract-syntax">unsigned_i7word_t</span></span> will be used very little,
but is an unsigned version of the same. (It must be the case that an <span class="extract"><span class="Extracts-extract-syntax">i7word_t</span></span>
can survive being cast to <span class="extract"><span class="Extracts-extract-syntax">unsigned_i7word_t</span></span> and back again intact.)
</p>

<p class="commentary"><span class="extract"><span class="Extracts-extract-syntax">i7byte_t</span></span> holds an Inter byte value, and must be unsigned.
</p>

<p class="commentary">It must unfortunately be the case that <span class="extract"><span class="Extracts-extract-syntax">i7float_t</span></span> values can be stored in
<span class="extract"><span class="Extracts-extract-syntax">i7word_t</span></span> containers at runtime, which is why they are only <span class="extract"><span class="Extracts-extract-syntax">float</span></span> and not
<span class="extract"><span class="Extracts-extract-syntax">double</span></span> precision.
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">typedef</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">int32_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-identifier-syntax">typedef</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">uint32_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">unsigned_i7word_t</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-identifier-syntax">typedef</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">unsigned</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">char</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7byte_t</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-identifier-syntax">typedef</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">float</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7float_t</span><span class="Extracts-plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<p class="commentary">Our library is going to be able to manage multiple independently-running
"processes", storage for each of which is a single <span class="extract"><span class="Extracts-extract-syntax">i7process_t</span></span> structure.
Within that, the current execution state is an <span class="extract"><span class="Extracts-extract-syntax">i7state_t</span></span>, which we now define.
</p>

<p class="commentary">The most important thing here is <span class="extract"><span class="Extracts-extract-syntax">memory</span></span>: the byte-addressable space
holding arrays and property values. (Note that, unlike the memory architecture
for the Z-machine or Glulx VMs, this memory space contains no program code. If
the same Inter code is compiled once to C, and then also to Glulx via Inform 6,
there will be some similarities between the C <span class="extract"><span class="Extracts-extract-syntax">memory</span></span> contents and the RAM-like
parts of the Glulx VM's memory, but only some. Addresses will be quite different
between the two.)
</p>

<p class="commentary">The valid range of memory addresses is between 0 and <span class="extract"><span class="Extracts-extract-syntax">himem</span></span> minus 1.
</p>

<p class="commentary">There is also a stack, but only a small one. Note that this does not contain
return addresses, in the way a traditional stack might: it simply holds values
which have explicitly been pushed by the Inter opcode <span class="extract"><span class="Extracts-extract-syntax">@push</span></span> and not yet pulled.
It doesn't live in memory, and cannot otherwise be read or written by the Inter
program; it is empty when <span class="extract"><span class="Extracts-extract-syntax">stack_pointer</span></span> is zero.
</p>

<p class="commentary">The object containment tree is also stored outside of memory; that's a choice
on our part, and makes it slightly faster to access. The same applies to the
array of global <span class="extract"><span class="Extracts-extract-syntax">variables</span></span>. (Again, this is a point of difference with the
traditional IF virtual machines, which put all of this in memory.)
</p>

<p class="commentary">The temporary value <span class="extract"><span class="Extracts-extract-syntax">tmp</span></span> holds data only fleetingly, during the execution of
a single Inter primitive or assembly opcode.
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-plain-syntax">#</span><span class="Extracts-identifier-syntax">define</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">I7_ASM_STACK_CAPACITY</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">128</span>
<span class="Extracts-plain-syntax">#</span><span class="Extracts-identifier-syntax">define</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">I7_TMP_STORAGE_CAPACITY</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">128</span>

<span class="Extracts-identifier-syntax">typedef</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">struct</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7rngseed_t</span><span class="Extracts-plain-syntax"> {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">uint32_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">A</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">uint32_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">interval</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">uint32_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">counter</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">} </span><span class="Extracts-identifier-syntax">i7rngseed_t</span><span class="Extracts-plain-syntax">;</span>

<span class="Extracts-identifier-syntax">typedef</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">struct</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7state_t</span><span class="Extracts-plain-syntax"> {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7byte_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">memory</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">himem</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">stack</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">I7_ASM_STACK_CAPACITY</span><span class="Extracts-plain-syntax">];</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">stack_pointer</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">object_tree_parent</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">object_tree_child</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">object_tree_sibling</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">variables</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">tmp</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">I7_TMP_STORAGE_CAPACITY</span><span class="Extracts-plain-syntax">];</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">current_output_stream_ID</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">struct</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7rngseed_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">seed</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">} </span><span class="Extracts-identifier-syntax">i7state_t</span><span class="Extracts-plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<p class="commentary">A "snapshot" is basically a saved state. At present, in fact, it is only that:
at one time this included a <span class="extract"><span class="Extracts-extract-syntax">jmp_buf</span></span> to preserve C stack state too, but that
turned out to be troublesome and unnecessary.
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">typedef</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">struct</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7snapshot_t</span><span class="Extracts-plain-syntax"> {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">valid</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">struct</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7state_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">then</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">} </span><span class="Extracts-identifier-syntax">i7snapshot_t</span><span class="Extracts-plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<p class="commentary">Okay then: a "process". This contains not only the current state but snapshots
of 10 recent states, in order to facilitate the UNDO operation. Snapshots are
stored in a form of ring buffer, to avoid ever copying them in memory: this
is because there is no remotely safe way to copy a <span class="extract"><span class="Extracts-extract-syntax">jmp_buf</span></span>, which (see above)
was at one time part of a snapshot.
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-plain-syntax">#</span><span class="Extracts-identifier-syntax">define</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">I7_MAX_SNAPSHOTS</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">10</span>
<span class="Extracts-identifier-syntax">typedef</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">struct</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7state_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">state</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7snapshot_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">snapshots</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">I7_MAX_SNAPSHOTS</span><span class="Extracts-plain-syntax">];</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">snapshot_pos</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">jmp_buf</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">execution_env</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">termination_code</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> (*</span><span class="Extracts-identifier-syntax">receiver</span><span class="Extracts-plain-syntax">)(</span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">wchar_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">char</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">style</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">send_count</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">char</span><span class="Extracts-plain-syntax"> *(*</span><span class="Extracts-identifier-syntax">sender</span><span class="Extracts-plain-syntax">)(</span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">count</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> (*</span><span class="Extracts-identifier-syntax">stylist</span><span class="Extracts-plain-syntax">)(</span><span class="Extracts-identifier-syntax">struct</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">which</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">what</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> (*</span><span class="Extracts-identifier-syntax">glk_implementation</span><span class="Extracts-plain-syntax">)(</span><span class="Extracts-identifier-syntax">struct</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">glk_api_selector</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">varargc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">z</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">struct</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">miniglk_data</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">use_UTF8</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">} </span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<p class="commentary firstcommentary"><a id="SP10" class="paragraph-anchor"></a><b>&#167;10. </b>Creator functions for each of the above:
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">i7state_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_new_state</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">i7snapshot_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_new_snapshot</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_new_process</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<p class="commentary">Note that an <span class="extract"><span class="Extracts-extract-syntax">i7state_t</span></span> begins with its potentially large arrays unallocated,
so it initially consumes very little memory.
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">i7state_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_new_state</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7state_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">memory</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">NULL</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">himem</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">stack_pointer</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">object_tree_parent</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">NULL</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">object_tree_child</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">NULL</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">object_tree_sibling</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">NULL</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">variables</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">NULL</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">seed</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_initial_rng_seed</span><span class="Extracts-plain-syntax">();</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>

<span class="Extracts-identifier-syntax">i7snapshot_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_new_snapshot</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7snapshot_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">SS</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">SS</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">valid</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">SS</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">then</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_new_state</span><span class="Extracts-plain-syntax">();</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">SS</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>

<span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_new_process</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">state</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_new_state</span><span class="Extracts-plain-syntax">();</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">for</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">=0; </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">&lt;</span><span class="Extracts-identifier-syntax">I7_MAX_SNAPSHOTS</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">++) </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">snapshots</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">] = </span><span class="Extracts-identifier-syntax">i7_new_snapshot</span><span class="Extracts-plain-syntax">();</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">snapshot_pos</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">receiver</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_default_receiver</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">send_count</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">sender</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_default_sender</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">stylist</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_default_stylist</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">glk_implementation</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_default_glk</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">use_UTF8</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">1</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_initialise_miniglk_data</span><span class="Extracts-plain-syntax">(&amp;</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<p class="commentary firstcommentary"><a id="SP11" class="paragraph-anchor"></a><b>&#167;11. </b>The <span class="extract"><span class="Extracts-extract-syntax">i7_new_process</span></span> function refers to two default functions attached to
a new process, so we must define those:
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">char</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">i7_default_sender</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">count</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_default_receiver</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">wchar_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">char</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">style</span><span class="Extracts-plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<p class="commentary">The receiver and sender functions allow our textual I/O to be managed by external
C code: see <a href="../inform7/M-cifc.html" class="internal">Calling Inform from C (in inform7)</a>.
</p>

<p class="commentary">The receiver is sent every character printed out; by default, it prints every
character sent to the body text window, while suppressing all others (for example,
those printed to the "status line" used by IF games).
</p>

<p class="commentary">The sender supplies us with textual commands. By default, it takes a typed (or
of course piped) single line of text from the C <span class="extract"><span class="Extracts-extract-syntax">stdin</span></span> stream.
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_default_receiver</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">wchar_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">char</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">style</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-identifier-syntax">I7_BODY_TEXT_ID</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">fputc</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">stdout</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">}</span>

<span class="Extracts-identifier-syntax">char</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_default_sender_buffer</span><span class="Extracts-plain-syntax">[256];</span>
<span class="Extracts-identifier-syntax">char</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">i7_default_sender</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">count</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">while</span><span class="Extracts-plain-syntax"> (1) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">getchar</span><span class="Extracts-plain-syntax">();</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> ((</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-identifier-syntax">EOF</span><span class="Extracts-plain-syntax">) || (</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> == '\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">') || (</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> == '\</span><span class="Extracts-identifier-syntax">r</span><span class="Extracts-plain-syntax">')) </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax"> &lt; </span><span class="Extracts-constant-syntax">255</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">i7_default_sender_buffer</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax">++] = </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_default_sender_buffer</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax">++] = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_default_sender_buffer</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<p class="commentary firstcommentary"><a id="SP12" class="paragraph-anchor"></a><b>&#167;12. </b>The C generator can produce either a stand-alone C program, including a <span class="extract"><span class="Extracts-extract-syntax">main</span></span>,
or else a file of C code intended to be linked into something larger. If it does
provide a <span class="extract"><span class="Extracts-extract-syntax">main</span></span>, then that function simply calls the following; it it does not,
then the following is never used.
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_default_main</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">argc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">char</span><span class="Extracts-plain-syntax"> **</span><span class="Extracts-identifier-syntax">argv</span><span class="Extracts-plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_default_main</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">argc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">char</span><span class="Extracts-plain-syntax"> **</span><span class="Extracts-identifier-syntax">argv</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_new_process</span><span class="Extracts-plain-syntax">();</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_run_process</span><span class="Extracts-plain-syntax">(&amp;</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">termination_code</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-constant-syntax">1</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">printf</span><span class="Extracts-plain-syntax">("*** </span><span class="Extracts-identifier-syntax">Fatal</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">error</span><span class="Extracts-plain-syntax">: </span><span class="Extracts-identifier-syntax">halted</span><span class="Extracts-plain-syntax"> ***\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">");</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fflush</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stdout</span><span class="Extracts-plain-syntax">); </span><span class="Extracts-identifier-syntax">fflush</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">termination_code</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<p class="commentary">If external code is managing the process, and <span class="extract"><span class="Extracts-extract-syntax">i7_default_main</span></span> is not used,
then that external code will still call <span class="extract"><span class="Extracts-extract-syntax">i7_new_process</span></span> and then <span class="extract"><span class="Extracts-extract-syntax">i7_run_process</span></span>,
but may in between the two supply its own receiver or sender:
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_set_process_receiver</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> (*</span><span class="Extracts-identifier-syntax">receiver</span><span class="Extracts-plain-syntax">)(</span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">wchar_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">char</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">style</span><span class="Extracts-plain-syntax">), </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">UTF8</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_set_process_sender</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">char</span><span class="Extracts-plain-syntax"> *(*</span><span class="Extracts-identifier-syntax">sender</span><span class="Extracts-plain-syntax">)(</span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">count</span><span class="Extracts-plain-syntax">));</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_set_process_receiver</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> (*</span><span class="Extracts-identifier-syntax">receiver</span><span class="Extracts-plain-syntax">)(</span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">wchar_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">char</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">style</span><span class="Extracts-plain-syntax">), </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">UTF8</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">receiver</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">receiver</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">use_UTF8</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">UTF8</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_set_process_sender</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">char</span><span class="Extracts-plain-syntax"> *(*</span><span class="Extracts-identifier-syntax">sender</span><span class="Extracts-plain-syntax">)(</span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">count</span><span class="Extracts-plain-syntax">)) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">sender</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">sender</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<p class="commentary">Similarly, ambitious projects which want their own complete I/O systems can
set the following:
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_set_process_stylist</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> (*</span><span class="Extracts-identifier-syntax">stylist</span><span class="Extracts-plain-syntax">)(</span><span class="Extracts-identifier-syntax">struct</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">which</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">what</span><span class="Extracts-plain-syntax">));</span>
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_set_process_glk_implementation</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> (*</span><span class="Extracts-identifier-syntax">glk_implementation</span><span class="Extracts-plain-syntax">)(</span><span class="Extracts-identifier-syntax">struct</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">glk_api_selector</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">varargc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">z</span><span class="Extracts-plain-syntax">));</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_set_process_stylist</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> (*</span><span class="Extracts-identifier-syntax">stylist</span><span class="Extracts-plain-syntax">)(</span><span class="Extracts-identifier-syntax">struct</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">which</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">what</span><span class="Extracts-plain-syntax">)) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">stylist</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">stylist</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_set_process_glk_implementation</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> (*</span><span class="Extracts-identifier-syntax">glk_implementation</span><span class="Extracts-plain-syntax">)(</span><span class="Extracts-identifier-syntax">struct</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">glk_api_selector</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">varargc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">z</span><span class="Extracts-plain-syntax">)) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">glk_implementation</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">glk_implementation</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<p class="commentary">In all cases, execution is kicked off when <span class="extract"><span class="Extracts-extract-syntax">i7_run_process</span></span> is called on a process.
Ordinarily, that will execute the entire Inform 7 program and then come back to us;
but we need to cope with a sudden halt during execution, either through a fatal
error or through a use of the <span class="extract"><span class="Extracts-extract-syntax">@quit</span></span> opcode.
</p>

<p class="commentary">We do that with the <span class="extract"><span class="Extracts-extract-syntax">setjmp</span></span> and <span class="extract"><span class="Extracts-extract-syntax">longjmp</span></span> mechanism of C. This is a very limited
sort of exception-handling will a well deserved reputation for crankiness, and we
will use it with due caution. It is essential that the underlying <span class="extract"><span class="Extracts-extract-syntax">jmp_buf</span></span> data
not move in memory for any reason between the setting and the jumping. (This is
why there is no mechanism to copy or fork an <span class="extract"><span class="Extracts-extract-syntax">i7_process_t</span></span>.)
</p>

<p class="commentary">Note that the <span class="extract"><span class="Extracts-extract-syntax">i7_initialiser</span></span> function is compiled and is not pre-written
like these other functions: see <a href="5-com.html" class="internal">C Object Model</a> for what it does.
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_run_process</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_benign_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_initialiser</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">); /* </span><span class="Extracts-identifier-syntax">part</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">of</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">the</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">compiled</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">story</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">not</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">inform_clib</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> */</span>
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_initialise_object_tree</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">); /* </span><span class="Extracts-identifier-syntax">ditto</span><span class="Extracts-plain-syntax"> */</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_fn_Main</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_run_process</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">tc</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">setjmp</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">execution_env</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">tc</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">tc</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-constant-syntax">2</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">termination_code</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">; /* </span><span class="Extracts-identifier-syntax">terminated</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">mid</span><span class="Extracts-plain-syntax">-</span><span class="Extracts-identifier-syntax">stream</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">but</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">benignly</span><span class="Extracts-plain-syntax"> */</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">else</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">termination_code</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">tc</span><span class="Extracts-plain-syntax">; /* </span><span class="Extracts-identifier-syntax">terminated</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">mid</span><span class="Extracts-plain-syntax">-</span><span class="Extracts-identifier-syntax">stream</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">with</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">fatal</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">error</span><span class="Extracts-plain-syntax"> */</span>
<span class="Extracts-plain-syntax">    } </span><span class="Extracts-identifier-syntax">else</span><span class="Extracts-plain-syntax"> {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">i7_initialise_memory_and_stack</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">i7_initialise_variables</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">i7_empty_object_tree</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">i7_initialiser</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">i7_initialise_object_tree</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">i7_initialise_miniglk</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">i7_fn_Main</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">termination_code</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">; /* </span><span class="Extracts-identifier-syntax">terminated</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">because</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">the</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">program</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">completed</span><span class="Extracts-plain-syntax"> */</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">termination_code</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>

<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">//  </span><span class="Extracts-identifier-syntax">Uncomment</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">the</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">next</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">line</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">to</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">force</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">crash</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">so</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">that</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">the</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">stack</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">can</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">be</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">inspected</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">in</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">debugger</span>
<span class="Extracts-plain-syntax">//  </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">x</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">printf</span><span class="Extracts-plain-syntax">("%</span><span class="Extracts-identifier-syntax">d</span><span class="Extracts-plain-syntax">", </span><span class="Extracts-constant-syntax">1</span><span class="Extracts-plain-syntax">/</span><span class="Extracts-identifier-syntax">x</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">longjmp</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">execution_env</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">1</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">}</span>

<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_benign_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">longjmp</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">execution_env</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">2</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="4-i6c2.html">&#10094;</a></li><li class="progresschapter"><a href="P-wtmd.html">P</a></li><li class="progresschapter"><a href="1-fm.html">1</a></li><li class="progresschapter"><a href="2-cg.html">2</a></li><li class="progresschapter"><a href="3-fti.html">3</a></li><li class="progresschapter"><a href="4-fi6.html">4</a></li><li class="progresscurrentchapter">5</li><li class="progresscurrent">fnc</li><li class="progresssection"><a href="5-cnm.html">cnm</a></li><li class="progresssection"><a href="5-crf.html">crf</a></li><li class="progresssection"><a href="5-cgv.html">cgv</a></li><li class="progresssection"><a href="5-cmm.html">cmm</a></li><li class="progresssection"><a href="5-cas.html">cas</a></li><li class="progresssection"><a href="5-car.html">car</a></li><li class="progresssection"><a href="5-cpc.html">cpc</a></li><li class="progresssection"><a href="5-ccn.html">ccn</a></li><li class="progresssection"><a href="5-clt.html">clt</a></li><li class="progresssection"><a href="5-com.html">com</a></li><li class="progresssection"><a href="5-cfm.html">cfm</a></li><li class="progresssection"><a href="5-cim.html">cim</a></li><li class="progresssection"><a href="5-cmn.html">cmn</a></li><li class="progresssection"><a href="5-cuf.html">cuf</a></li><li class="progressnext"><a href="5-cnm.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

